<%@ page contentType="application/PDF;charset=GBK" %><%@ page import="java.util.*" %><%@ page import="java.io.File" %><%@ page import="com.ionglobal.lib.*" %><%@ page import="com.ionglobal.misc.*" %><%@ page import="com.ionglobal.report.*" %><%@ page import="com.dhec.ggs.*"%><%@ page import="com.ionglobal.ggs.Esignature" %><%@ include file="/inc/init_include.jsp" %><%
	int surveyId=Request.getInt("id",0);
	int dcnId=Request.getInt("dcnid",0);
	String issue1=Request.getString("issue1","0");
	String issue2=Request.getString("issue2","0");
	
	Sysop sysop = (Sysop)session.getAttribute("sysop");
	ApproveSurveyApp sApp=new ApproveSurveyApp();
	AppSurverDetailApp  dApp=new AppSurverDetailApp();
	ApproveSurvey survey=sApp.getApproveSurvey(dbi, surveyId);
	DesignChangeApp dcApp = new DesignChangeApp();
	DesignChange dc = null;
	if(dcnId>0)
		dc=dcApp.getDesignChange(dbi, dcnId);
	else
		dc=dcApp.getDesignChange(dbi, survey.getDCNo());

	if(survey!=null){
		Map paraMap = new HashMap();
		paraMap.put("dcno", survey.getDCNo());
		paraMap.put("parentId", survey.getId()+"");
		if(dc.getOtherDCNo().length()>0){
			String[] dcnos = dc.getOtherDCNo().split(",");
			if(dcnos.length>0)
				paraMap.put("otherDCNo1", dcnos[0]);
			if(dcnos.length>1)
				paraMap.put("otherDCNo2", dcnos[1]);
			if(dcnos.length>2)
				paraMap.put("otherDCNo3", dcnos[2]);
		}
		paraMap.put("spname", survey.getSPName());
		Date now = new Date();
		Calendar cal = Calendar.getInstance();
		if(dc.getSurveyIssueDate()!=null && dc.getSurveyIssueDate().getTime()>=survey.getCrDate().getTime())
			cal.setTime(dc.getSurveyIssueDate());
		else
			cal.setTime(now);
		paraMap.put("year", cal.get(Calendar.YEAR)+"");
		paraMap.put("month", (cal.get(Calendar.MONTH)+1)+"");
		paraMap.put("day", cal.get(Calendar.DAY_OF_MONTH)+"");
		paraMap.put("requestdate", survey.getRequestDate());
		paraMap.put("descript", survey.getDescribe());
		paraMap.put("remark", survey.getRemark());
		File techUserSign = Esignature.getFile(dc.getTechUser());
		if(techUserSign!=null)
			paraMap.put("techUserSign", techUserSign);
		File auditUserSign = Esignature.getFile(dc.getSTechConfirm());
		if(auditUserSign!=null)
			paraMap.put("auditUserSign", auditUserSign);
		
		if(survey.getApproveSide()==2){
			File approveUserSign = Esignature.getFile(survey.getApproveUser());			
			if(approveUserSign!=null){
				paraMap.put("ApproveUserSign", approveUserSign);
				File counselSign = Esignature.getFile(survey.getCounsel());
				if(counselSign!=null){
					paraMap.put("CounselSign", counselSign);
				}
				
			}
			
			paraMap.put("ApproveContent", survey.getApproveContent());
		}
						
		String sourcePath = SysEnv.getFileRoot();
		Report report = new Report();
		try {
			File reportFile = new File(sourcePath+"/reports/ApproveSurvey.jasper");
			String reportName = "approvesurveyTable.pdf";

			response.reset(); 
			response.setCharacterEncoding("GBK");
			response.setContentType("application/pdf");
			response.setHeader("Content-Disposition", "filename="+reportName);

			report.setDestFile(sourcePath + reportName);
			report.setReportFile(reportFile.getPath());
			report.setParameters(paraMap);
			report.setConnection(dbi.getConnection());
			report.setResponse(response);
			report.getReport("PDF",reportName);
		} catch (Exception e) {
			 e.printStackTrace();
		}
	}%><%@ include file="/inc/init_free.jsp" %>

